package day06;

import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.Scanner;

public class CrawlerDemo {
    public static void main(String[] args) {
        try {
            URL name = new URL("https://www.ahut.edu.cn");
            BufferedOutputStream bos = new BufferedOutputStream((new FileOutputStream("ahut.html")));
            PrintWriter cout = new PrintWriter(bos);

            InputStream ips = name.openStream();
            Scanner cin = new Scanner(new BufferedInputStream(ips));
            int lineNumber = 0;
            while (cin.hasNextLine()) {
                cout.println(cin.nextLine());
            }
            Runtime.getRuntime().exec("explorer.exe ahut.html");
            cout.close();
        } catch (java.io.IOException e) {
            e.printStackTrace();
        }
    }
}
